<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<title>SCOTT开发框架</title>
<!--网页标题左侧显示-->
<link rel="icon" href="${ctxPath}/static/images/favicon.png" type="image/x-icon">
<!--收藏夹显示图标-->
<link rel="shortcut icon" href="${ctxPath}/static/images/favicon.png" type="image/x-icon">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"/>
<link rel="stylesheet" href="${ctxPath}/static/css/login.min.css"/>
</head>
<body>
	<div class="login">
		<div class="message">SCOTT 管理登录</div>
		<div id="darkbannerwrap"></div>
		<form action="${ctxPath}/login" method="post" id="loginForm">
            <!--<h4 class="tip">${errorMsg!}</h4>-->
            <input type="hidden" id="tip" name="tip" type="text" class="tip" value="${errorMsg!}">
			<input placeholder="用户名" id="username" name="username" type="text" class="loginInput" value="admin">
			<hr class="hr15">
			<input placeholder="密码" id="password" name="password" type="password" class="loginInput" value="123456">
			<hr class="hr15">
			@if(kaptchaEnable){
			<input placeholder="验证码" id="code" name="code" type="text" class="codeInput loginInput">
			<img src="captcha.jpg" alt="验证码" id="imgCode" class="codeImg" title="单击图片刷新！">
			<hr class="hr15">
			@}
			<input value="登录" style="width: 100%;" type="button" id="loginBtn">
			<hr class="hr20">
            <p class="copyright">
                版权所有 © 2018 SCOTT - Powered By Mr.薛
            </p>
		</form>
	</div>
	<script src="${ctxPath}/static/libs/jquery.min.js"></script>
    <script src="${ctxPath}/static/plugins/layer/layer.js"></script>
	<script type="text/javascript">

        $(function(){
            if (self != top) {
                top.location.href = self.location.href;
            }
            if($('.tip').val()!=""){
                layer.msg($('.tip').val());
                $('#username').focus();
            }
            $('#loginBtn').on('click', login);

            @if(kaptchaEnable){
            $('#imgCode').on('click', refreshCode);
            @}

            $(document).keyup(function (event) {
				if (event.keyCode === 13) {
				    $('#loginBtn').trigger('click');
				}
            })

        });

        @if(kaptchaEnable){
        function refreshCode() {
            $('#imgCode').attr('src', "captcha.jpg?t=" + $.now());
		}
		@}

        function login() {
            IsPC();
            var username = $('#username').val();
            if (username === '') {
                layer.msg("用户名不能为空");
                $('#username').focus();
                /*$('.tip').text('用户名不能为空');*/
                return false;
            }
            var password = $('#password').val();
            if (password === '') {
                /*$('.tip').text('密码不能为空');*/
                layer.msg("密码不能为空");
                $('#password').focus();
                return false;
            }
            @if(kaptchaEnable){
			var code = $('#code').val();
			if (code === '') {
				/*$('.tip').text('验证码不能为空');*/
                layer.msg("验证码不能为空");
                $('#code').focus();
				return false;
			}
            @}
            $('#loginForm').submit();
        }

        /*PC识别*/
        function IsPC() {
            var userAgentInfo = navigator.userAgent;
            var Agents = ["Android", "iPhone",
                "SymbianOS", "Windows Phone",
                "iPad", "iPod"];
            console.log("设备："+userAgentInfo);
            var flag = true;
            for (var v = 0; v < Agents.length; v++) {
                if (userAgentInfo.indexOf(Agents[v]) > 0) {
                    flag = false;
                    if (userAgentInfo.indexOf('Android') > -1 || userAgentInfo.indexOf('Linux') > -1) {
                        //安卓手机
                        console.log("设备：安卓手机");
                    } else if (userAgentInfo.indexOf('iPhone') > -1) {
                        //苹果手机
                        console.log("设备：苹果手机");
                    } else if (userAgentInfo.indexOf('Windows Phone') > -1) {
                        //winphone手机
                        console.log("设备：winphone手机");
                    }
                    console.log("是否微信："+isWeiXin);
                    break;
                }else{
                    console.log("设备：windows/电脑在线");
                    break;
                }
            }
            return flag;
        }

        function isWeiXin(){
            var ua = navigator.userAgent.toLowerCase();
            if(ua.indexOf('micromessenger') != -1) {
                return true;
            } else {
                return false;
            }
        }

	</script>
</body>
</html>
